package com.zaoniao.enstudy.api.vo;

import com.zaoniao.enstudy.domain.entity.ZaoWord;
import com.zaoniao.enstudy.domain.entity.ZaoWordExample;
import com.zaoniao.enstudy.infracore.constants.AppConstant;
import com.zaoniao.enstudy.infracore.web.PagedGridResult;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author llb666
 */
@Data
public class ZaoWordVo {

    /**
     * 主键id.
     */
    private Long id;

    /**
     * 年级.
     */
    private String grade;

    /**
     * 单词.
     */
    private String word;

    /**
     * 中文翻译.
     */
    private String translation;

    /**
     * 音标.
     */
    private String phoneticSymbol;

    /**
     * 发音，音频链接地址.
     */
    private String pronunciation;

    /**
     * 是否当前用户收藏.
     */
    private Integer isMyVocabulary;

    public String getPronunciation (){
        return AppConstant.AUDIO_PREFIX + pronunciation;
    }

    private List<ZaoWordExample> wordExamples;

    @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
    public interface Converter {

        ZaoWordVo.Converter INSTANCE = Mappers.getMapper(ZaoWordVo.Converter.class);

        ZaoWordVo do2Vo(ZaoWord word);

        /**
         * doList转voList
         * @param wordList -
         * @return -
         */
        List<ZaoWordVo> do2VoList(List<ZaoWord> wordList);

        PagedGridResult<ZaoWordVo> do2voPage(PagedGridResult<ZaoWord> pagedGridResult);
    }
}
